package com.work.music.dao;

import com.work.music.entity.Feedback;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;

@Repository
public interface FeedbackMapper {
    @Delete({
        "delete from music_feedback",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into music_feedback (id, uid, ",
        "addtime, addip, ",
        "status, content)",
        "values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=BIGINT}, ",
        "#{addtime,jdbcType=TIMESTAMP}, #{addip,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR})"
    })
    int insert(Feedback record);

    @Select({
        "select",
        "id, uid, addtime, addip, status, content",
        "from music_feedback",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT),
        @Result(column="addtime", property="addtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="addip", property="addip", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    Feedback selectByPrimaryKey(String id);

    @Select({
        "select",
        "id, uid, addtime, addip, status, content",
        "from music_feedback"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="uid", property="uid", jdbcType=JdbcType.BIGINT),
        @Result(column="addtime", property="addtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="addip", property="addip", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Feedback> selectAll();

    @Update({
        "update music_feedback",
        "set uid = #{uid,jdbcType=BIGINT},",
          "addtime = #{addtime,jdbcType=TIMESTAMP},",
          "addip = #{addip,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Feedback record);
}